package com.zhouxiaoge.职责链模式.two;

/**
 * @author 周小哥 gqzmy@163.com 2022/10/8 13:46
 */

public abstract class Handler {

    private int level = 0;

    private Handler nextHandler;

    public Handler(int level) {
        this.level = level;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public final void handleMessage(IWomen iWomen) {
        if (iWomen.getType() == this.level) {
            this.response(iWomen);
        } else {
            if (this.nextHandler != null) {
                this.nextHandler.handleMessage(iWomen);
            } else {
                System.out.println("--------------------没有地方请示了,不做处理--------------------");
            }
        }
    }

    public abstract void response(IWomen iWomen);
}
